import commonPage from '../../commonPage.js'

class Test extends commonPage {
  constructor(...args) {
    super(...args);
    super.$init({
      test: 12,
      arr: []
    });
  }

  $onNavigator(query) {
    console.log("开始获取数据 TESTPAGE 还没加载", query.count);
    //这时候调用commonPage类中的异步获取数据的方法
    this.getData(query.count)
  }
  onLoad() {
    console.log('TESTPAGE 加载');
    console.log(this.data);

    if(this.data.arr.length == 0) {
      console.log('arr empty')
    }
  }

  onReady() {}

  getData = function (count) {
    console.log("获取数据函数")
    var t_arr = [];
    setTimeout(() => {
      for (var i = 0; i < count; i++) {
        t_arr.push({ num: "第" + i })
      }
      this.data.arr = t_arr
      this.$setData(this.data)
    }, 200)
  }
}

Page(new Test({clazzName:'../test/test'}))
//Page(new Test())  //

